#!/bin/bash

declare -a scripts=(
    "/home/zuo/25_OA自动化下载/Task/DownLoader.py"
)

stop_processes() {
    echo "停止进程 ..."
    for script in "${scripts[@]}"; do
        pkill -f "$script"
    done
}

start_processes() {
    echo "启动进程 ..."
    log_dir="/home/zuo/25_OA自动化下载/log"
    mkdir -p "$log_dir"
    current_hour=$(date "+%Y%m%d_%H")  # 获取当前日期和小时，格式为 YYYYMMDD_HH
    for script in "${scripts[@]}"; do
        script_name=$(basename "$script")
        log_file="$log_dir/${script_name%.*}_$current_hour.log"  # 日志文件名包含当前小时
        nohup python3 -u "$script" > "$log_file" 2>&1 &
    done
}

stop_processes
sleep 5
start_processes
# */10 * * * * /home/zuo/Arxiv全文向量处理/ReStart.sh
